import React from 'react';
import TodoList from './TodoList.js'

class TodoApp extends React.Component{
	constructor(props){
		super(props);
		this.addtodo=this.addtodo.bind(this);
		this.removeTodo=this.removeTodo.bind(this);
	}

	addtodo(){
		var content=this.refs.content.value;
		this.props.AddTodo({
			type:"ADD_TODO",
			text:content
		})
	}

	removeTodo(index){
		this.props.Removeli({
			type:"REMOVE_TODO",
			index:index
		})
	}

	render(){
		return(
			<div>
				<input type="text" ref="content"/>
				<button onClick={this.addtodo}>邱神</button>
				<TodoList list={this.props.list} remove={this.removeTodo}/>
			</div>
		)
	}
}

export default TodoApp